/*
 * RectangleTest.cpp
 *
 *  Created on: 06-12-2010
 *      Author: Przemek
 */

#include "geometry/Rectangle.hpp"
#include "utils/MathUtils.hpp"

#define BOOST_TEST_MODULE Rectangle test
#include <boost/test/unit_test.hpp>
using namespace std;

BOOST_AUTO_TEST_CASE( translateTest )
{
	const geometry::Rectangle rectangle(Vector(), Dimension(100, 100));

	BOOST_CHECK_EQUAL(MathUtils::isEqual(rectangle.getPosition().getX(), 0.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(rectangle.getPosition().getY(), 0.0f),true);

	const geometry::Rectangle translated = rectangle.translate(Vector(10, 20));
	BOOST_CHECK_EQUAL(MathUtils::isEqual(translated.getPosition().getX(), 10.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(translated.getPosition().getY(), 20.0f),true);
}

BOOST_AUTO_TEST_CASE( containsTest )
{
	geometry::Rectangle rectangle(Vector(), Dimension(100, 100));

	BOOST_CHECK_EQUAL(rectangle.contains(Vector(-10, -10)), false);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(0, -10)), false);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(0, 0)), true);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(10, 10)), true);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(100, 100)), true);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(120, 100)), false);
	BOOST_CHECK_EQUAL(rectangle.contains(Vector(120, 120)), false);
}
